import QtQuick 2.15
import QtQuick.Controls 2.15
import "."

Item {
    id: mainPage

    property var settingsItems: [
        { name: "主题设置", icon: "🎨", page: "Test1.qml" },
        { name: "界面设置", icon: "🖥️", page: "Test2.qml" },/*
        { name: "杂项设置", icon: "⚙️", page: "MiscSettings.qml" },
        { name: "热键设置", icon: "⌨️", page: "HotkeySettings.qml" },
        { name: "当前配置", icon: "📋", page: "ConfigSettings.qml" },
        { name: "应用目录", icon: "📁", page: "AppDirectory.qml" },
        { name: "内核目录", icon: "🔧", page: "KernelDirectory.qml" },
        { name: "日志目录", icon: "📝", page: "LogDirectory.qml" },
        { name: "检查更新", icon: "🔄", page: "UpdateCheck.qml" }*/
    ]

    Rectangle {
        anchors.fill: parent
        color: "#f5f5f5"

        Column {
            anchors.fill: parent

            // 标题栏
            Rectangle {
                width: parent.width
                height: 60
                color: "#ffffff"

                Text {
                    text: "服务"
                    font.pixelSize: 20
                    font.bold: true
                    anchors.centerIn: parent
                }
            }

            // 设置项表格
            ScrollView {
                width: parent.width
                height: parent.height - 60

                Item {
                    width: parent.width
                    height: childrenRect.height

                    Grid {
                        id: settingsGrid
                        anchors.left: parent.left
                        anchors.right: parent.right
                        anchors.top: parent.top
                        anchors.margins: 10
                        columns: 2
                        columnSpacing: 10
                        rowSpacing: 10

                        Repeater {
                            model: settingsItems

                            SettingsItem {
                                width: (settingsGrid.width - settingsGrid.columnSpacing) / 2
                                itemName: modelData.name
                                itemIcon: modelData.icon

                                onClicked: {
                                    stackView.push(modelData.page, {
                                        "pageTitle": modelData.name,
                                        "pageIcon": modelData.icon
                                    })
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
